package com.service.khqy;

import java.util.Vector;

import com.bpms.common.CommonUtil;
import com.bpms.common.JdbcWorker;
import com.bpms.common.VO;
import com.bpms.common.VOL;
import com.bpms.common.VOList;
import com.bpms.esb.IService;

public class Cancelaccountinfo implements IService {

	public VO exec(VO arg0) {
		JdbcWorker j = null;
		VO vo = new VO();
		try {
			j = new JdbcWorker();
			j.startTransaction();
			try {

				VO v = new VO();
				v.setAttr("AVAILABLE", "2");

				String id = arg0.getAttr("ID");
				VO k = new VO();
				k.voType = "ACCOUNTINFO";
				k.keyString = "ID";
				k.setAttr("ID", id);
				j.update(v, k);

				String sql = "select * from ACCOUNTNO where ACCOUNTID='" + id
						+ "'";
				VOList volist = j.readAll(new VO(), sql);
				VOL vol = new VOL(volist);
				Vector<VO> vector = vol.listData;

				VO vv = new VO();
				vv.setAttr("AVAILABLE", "2");

				VO k1 = new VO();
				k1.voType = "ACCOUNTNO";
				k1.keyString = "ACCOUNTID";
				k1.keyString = "ACCOUNT";
				k1.setAttr("ACCOUNTID", id);

				for (VO v2 : vector) {
					k1.setAttr("ACCOUNT", v2.getAttr("account"));
					j.update(vv, k1);
				}
				j.commit();

				vo.setAttr("result", "1");
				vo.setAttr("msg", "注销簽約成功");
			} catch (Exception e) {
				CommonUtil.debug("Cancelaccountinfoinner exception", e);
				vo.setAttr("result", "9999");
				vo.setAttr("msg", "获得签约错误");
				j.rollback();
			}
		} catch (Exception e) {
			CommonUtil.debug("Cancelaccountinfo exception", e);
			vo.setAttr("result", "9999");
			vo.setAttr("msg", "获得签约错误");
		}

		return vo;
	}

}
